<?
$plans=get_plan_settings($id);

$i=0;

$params[sid] = $sid;
$params[action] = 'editPlans';
$prices_url = "$baseURL/$webDIR/?".encode_params($params);
$params[action] = 'managePlans2';
$url= "$baseURL/$webDIR/?".encode_params($params);
foreach($plans as $p){

	$checked1="";
	if($p[offering]=="true") $checked1="checked";
	if(!$p[setup_fee]) $p[setup_fee]="<a href='$prices_url'>set prices</a>";
	if(!$p[plan_price]) $p[plan_price]="<a href='$prices_url'>set prices</a>";
	if(!$p[domain_price]) $p[domain_price]="<a href='$prices_url'>set prices</a>";

	$product_offering.="<TR>
				<TD><input onClick='check_product(this)' id='product_$i' $checked1 type='checkbox' name='plans[$i][offering]'></TD>
				<TD>$p[plan]</TD>
			</TR>
			<input type='hidden' name='plans[$i][plan]' value='$p[plan]'>
			\n\n";
	$checked2="";
	if($p[display_on_index]=='true') $checked2="checked";
	$products_on_index.="<TR id='index_tr_$i' slign='center'>
				<TD><input id='index_$i' $checked2 type='checkbox' name='plans[$i][display_on_index]' ></TD>
				<TD>$p[plan]</TD>
			</TR>\n\n";

	if($p[has_domain]!='false') $has_true="checked";
	if($p[has_domain]=='inplan') $has_inplan="checked";
	$domains="<TR>
			<TD valign=top><input type='checkbox' ' name='has_domain'  $has_true></TD>
			<TD colspan=5>" .  translate('sell_domain_hosting') . "<br><br>
				<input type='checkbox' ' name='has_domain_inplan'  $has_inplan onClick='window.open(\"fdo_aa_popup.html\", \"fdo_aa_popup\", \"width=300,height=150,top=400,left=300,screenX=400,screenY=300\")'>&nbsp;&nbsp;" . translate('offer_free_domain') . "

			</TD>

		</TR>\n\n";
//domains.="<TR>
  //                    <TD><input type='checkbox' ' name='has_domain_inplan'  $has_inplan></TD>
    //                  <TD colspan=5>Offer FREE domain name</TD>
      //        </TR>\n\n";
	$i++;
        $dplans = list_plan_details($p[plan],'array');
        if(is_array($dplans)){
          $desctable .= "<tr><td>$p[plan]:</td><td>".implode(",",array_slice(explode("|",$dplans[0][description]),0,6))."</td></tr>";
        }
}
?>

<script>
        numElem=<?echo $i?>;
        disabled_background="#E5E4E4";
        function init(){
                for(i=0;i<numElem;i++){
                        product_check=document.getElementById("product_"+i);
                        index_check=document.getElementById("index_"+i);
                        index_tr=document.getElementById("index_tr_"+i);
                        //alert(index_tr.style.backgroundColor);
                        if(product_check.checked == false) {
                                index_check.disabled = true;
                                index_tr.style.backgroundColor=disabled_background;
                        }
                }
        }

        function check_product(elem){
                index_check=document.getElementById(elem.id.replace("product","index"));
                index_tr=document.getElementById(elem.id.replace("product","index_tr"));
                if(elem.checked == false){
                        index_check.checked = false;
                        index_check.disabled = true;
                        index_tr.style.backgroundColor=disabled_background;
                }else {
                        index_tr.style.backgroundColor="#F5F4EF";
                        index_check.disabled = false;
                }
        }
        function show_help(file){

        var sFeatures = ""+
                " channelmode = no,"+
                " directories = no,"+
                " fullscreen = no,"+
                " height = 140"+
                " left = "+((screen.width/2)-250)+","+
                " location = no,"+
                " menubar = no,"+
                " resizable = no,"+
                " scrollbars = yes,"+
                " status = no,"+
                " titlebar = no,"+
                " toolbar = no,"+
                " top = "+((screen.height/2)-250)+","+
                " width =  530";




        if (file){
                 win_pop =  window.open(file,"", sFeatures,"");

        }

}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><font class="text"><b><?=translate('products_offer');?></b><br>
      <br>
      <?= translate('from_this_section');?>:<br/>
      <br>
      1. <?=translate('hosting_domain')?>.<br>
      2. <?=translate('hosting_free_domain')?> - <a href='#' onClick="show_help('freedomains.html')"><?=translate('click_here');?></a>.<br>
      3. <?=translate('web_hosting_only');?>.</font><br><br></td>
  </tr>
</table>
<form action='<?=$url?>' method='POST'>

<TABLE width="300" class='bTable' cellspacing=0>
<TR>
	  <TH colspan="2" align='center'><?= translate('select_products');?></TH>

</TR>
<TR>
	<td width="20" align="center"><strong>~</strong></td>
	<td><strong><?= translate('products_list');?></strong></td>
</TR>


<?echo $product_offering?>
<?echo $domains?>
</TABLE>
<br><br>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="2"><font class="text"><?= translate('below_select');?></font></td>
    </tr>
  </table>
  <br>

<TABLE width="300" class='bTable' cellspacing=0>
<TR>
	  <TH colspan=2 align='center'><?= translate('products_index');?></TH>

</TR>
<TR>
	<td width="20" align="center"><strong>~</strong></td>
	<td><strong><?= translate('select_products');?></strong></td>
</TR>
<?echo $products_on_index?>
</table>
<br><br><br>
<script>init();</script>
<input type='submit' value='<?= translate('save_settings');?>'>
</form>